import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;


public class SortDriver {
    public static void main(String[] args) throws Exception{
        Configuration conf = new Configuration();
        Job job = Job.getInstance(conf);

        job.setJarByClass(SortDriver.class);

        job.setMapperClass(SortMapper.class);
        job.setReducerClass(SortReducer.class);

        job.setSortComparatorClass(keyComp.class);

        job.setMapOutputKeyClass(IntWritable.class);
        job.setMapOutputValueClass(IntWritable.class);

        job.setOutputKeyClass(IntWritable.class);
        job.setOutputValueClass(IntWritable.class);

//        FileInputFormat.setInputPaths(job,"D:\\Filework\\input");
//        FileOutputFormat.setOutputPath(job,new Path("D:\\Filework\\output"));
        FileInputFormat.setInputPaths(job,"//wordcount//input");
        FileOutputFormat.setOutputPath(job,new Path("//wordcount//output"));

        boolean b = job.waitForCompletion(true);
        System.exit(b?0:1);
    }
}
